package cn.zcy.untils;

import io.jsonwebtoken.Claims;

import java.util.HashMap;
import java.util.Map;

public class Test {
    public static void main(String[] args) {
        try {
            JwtUtil jwtUtil = new JwtUtil();
            Map<String, Object> claims = new HashMap<>();
            claims.put("username", "user1");

            // 生成 JWT
            String token = jwtUtil.generateToken(claims);
            System.out.println("Generated Token: " + token);

            // 验证 JWT
            Claims parsedClaims = jwtUtil.validateToken(token);
            String username = parsedClaims.get("username",String.class);
            System.out.println("username = " + username);
            System.out.println("Parsed Claims: " + parsedClaims);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
